<!--{template dzapp_zhibo:header}-->

<!--{if $zhibo[tab_title]}-->
<style>
.tab-wrap a {
    width: 33.33%;
}
</style>
<!--{/if}-->

<div class="zhibo_info">
	<h1>{$zhibo[name]} </h1>
	<span>{lang dzapp_zhibo:live_time} {$zhibo[start_time]} {lang dzapp_zhibo:to} {$zhibo[end_time]}</span>
</div>

<!--{if $zhibo[scroll_advert]}-->
<a href="{if $zhibo[scroll_advert_url]}$zhibo[scroll_advert_url]{else}javascript{/if}">
	<div class="marquee">
		<marquee><!--{if !$video}-->{$zhibo[scroll_advert]}<!--{else}-->{lang dzapp_zhibo:zhibo_end_back}<!--{/if}--></marquee>
	</div>
</a>
<!--{/if}-->

<div class="burl cl">
<!--{if !$video}-->
<div id="player" style="width:100%;height:163px;">
    <script type="text/javascript" charset="utf-8" src="http://yuntv.letv.com/player/live/blive.js"></script>
    <script>
        var player = new CloudLivePlayer();
        player.init({activityId:"{$zhibo[activityid]}"});
    </script>
</div>
<!--{else}-->
<div id="player" style="width:100%;">
<iframe src="http://yuntv.letv.com/bcloud.html?uu=3pk1qptwwj&vu={$video[videoUnique]}&auto_play=1&width=100%&height=100%"></iframe>
</div>
<!--{/if}-->
</div>
<div class="cl"></div>
<!--{if $zhibo[advert]}-->
<div class="advert cl">
	<a href="{if $zhibo[advert_url]}$zhibo[advert_url]{else}javascript:;{/if}"><img src="{$zhibo[advert]}" /></a>
</div>
<!--{/if}-->

<div class="tab-wrap">
<!--{if $zhibo[graphic_status]}-->
	<a id="one1" onclick="setTab('one',1,{$tab_num})" class="active" href="javascript:void(0)">{lang dzapp_zhibo:live_chat}</a>
	<a id="one2" onclick="setTab('one',2,{$tab_num})" href="javascript:void(0)">{lang dzapp_zhibo:graphic_live}</a> 
	<!--{if $zhibo[tab_title]}-->
	<a id="one3" onclick="setTab('one',3,{$tab_num})" href="javascript:void(0)">$zhibo[tab_title]</a> 
	<!--{/if}-->
<!--{else}-->
	<span>{lang dzapp_zhibo:interactive_review}</span>
<!--{/if}-->
</div>
<div id="con_one_1" class="pannel pinglun hover">

	<div class="comment-top" >
		<a href="javascript:void(0)" data-praise="$zhibo[activity_id]"><img src="source/plugin/dzapp_zhibo/static/image/zan.png"><em>$zhibo[praise]</em></a>
		<div id="postcomment" {if !$in_wx} style="width:75%"{/if}>{lang dzapp_zhibo:zhibo_html_3}</div>
		<!--{if $in_wx}-->
		<a href="javascript:void(0)" data-gift-close="gift_button"><img src="source/plugin/dzapp_zhibo/static/image/gift.png"></a>
		<!--{/if}-->
	</div>
	<div class="gift_list">
		<div class="close" data-gift-close="gift_button"></div>
		<form id="payform" class="payselect" action="plugin.php?id=dzapp_zhibo&mod=view&identify=$_GET[identify]" method="post">
			<input type="hidden" name="formhash" id='formhash' value="{FORMHASH}" />
			<input type="hidden" name="paysubmit" value="yes" />
			<input type="hidden" id="gift_id" name="gift_id" />
			<input type="hidden" name="identify" id="identify" value="$_GET[identify]" />
                
			<ul>
				<!--{loop $glist $value}-->
				<li data-gift="$value[gift_id]"><img src="$value[icon]"><div class="name">$value[name]</div><div class="price">RMB:$value[price]</div></li>
				<!--{/loop}-->
			</ul>
		</form>
	</div>

	<div class="newpl">
		<ul class="comment ajaxnewcomment">			
		</ul>
		<div class="load-more" style="text-align: center;"><a class="next-page-link" href="javascript:void(0)">{lang dzapp_zhibo:load_more}</a></div>
	</div>
</div>

<div id="con_one_2" class="pannel content" style="display:none">
	<!--{if $_G[username] && in_array($_G[username], $manager)}-->
	<div class="comment-top" id="post_pic">
		<button id="postgraphic" type="button">{lang dzapp_zhibo:send_text}</button>
	</div>
	<!--{/if}-->
	
	<div class="newpl">
		<ul class="comment ajaxnewgraphic">
			
		</ul>
		<div class="load-more" style="text-align: center;"><a class="next-page-link" href="javascript:void(0)">{lang dzapp_zhibo:load_more}</a></div>
	</div>
</div>

<!--{if $zhibo[tab_title]}-->
<div id="con_one_3" class="pannel content" style="display:none">	
	<div class="newpl">
		$zhibo[tab_content]
	</div>
</div>
<!--{/if}-->

<div id="post_comment" class="post hide">
	<div class="post-content">
		<div>
		<textarea id="content" placeholder="{lang dzapp_zhibo:your_comments}"></textarea>
		<button id="postClose" class="btn close" type="button">{lang dzapp_zhibo:cancel}</button>
		<button class="btn" onclick="add()" id="submit" type="submit">{lang dzapp_zhibo:determine}</button>
		</div>
	</div>
</div>
<div id="post_graphic" class="post hide">
	
	<div class="post-content">
		<div>
		<form id="upload_graphic_form" name="upload_graphic_form" action="plugin.php?id=dzapp_zhibo&mod=ajax&ac=upload" method="POST" target="exec_target" enctype="multipart/form-data">
			<input type="hidden" name="activity_id" value="{$_GET[identify]}" />
			<input type="hidden" name="formhash" id='formhash' value="{FORMHASH}" />
			<input type="hidden" name="graphicsubmit" value="yes" />
			<div id="file_area">
			<input type="file" name="pic" id="pic" style="margin:8px;" />
			<button  id="gsubmit" type="submit" style="display:none"></button>
			</div>
		</form>
		<textarea id="describe" placeholder="{lang dzapp_zhibo:input_description}"></textarea>
		<input type="hidden" id="pic_url" value="" />
		<button class="btn close" type="button">{lang dzapp_zhibo:cancel}</button>
		<button class="btn" onclick="upload_graphic()"  id="submit" type="submit">{lang dzapp_zhibo:determine}</button>
		</div>
	</div>
	
</div>
<iframe id="exec_target" name="exec_target" style="display:none"></iframe> 
<script src="source/plugin/dzapp_zhibo/static/js/jquery.js"></script>
<script src="source/plugin/dzapp_zhibo/static/js/layer.js"></script>

<script>
var page = 1, gpage = 1;
contentlist();

$(document).ready(function () {
	
	$('[data-praise]').click(function(){
		var obj = $(this).find('em');
		$.ajax({ 
			url : 'plugin.php?id=dzapp_zhibo&mod=ajax&ac=praise', 
			dataType : 'json', 
			data : {activity_id:$(this).attr('data-praise'), formhash:'{FORMHASH}'},
			beforeSend:function(){
				obj.html(parseInt(obj.html()) + 1);
			},
			success : function(data, status){ 
				
			}
		})
	});
	
	$('[data-gift-close]').click(function(){
		if($('.gift_list').hasClass('cur')){
			$('.gift_list').removeClass('cur');
		} else {
			$('.gift_list').addClass('cur');
		}
	});
	
	$("#postcomment").click(function () {
		var isLogin = '$_G[uid]'; 
		if(parseInt(isLogin) > 0){
			
			$("#post_comment").removeClass("hide");
			document.getElementById("content").value="";
			document.getElementById("content").placeholder="{lang dzapp_zhibo:your_comments}";
			
		}else{
			location.href= 'member.php?mod=logging&action=login';
		}
	});	
	$("#post_pic").click(function () {
		$("#post_graphic").removeClass("hide");
	});	
	$(".close").click(function () {
		$(".post").addClass("hide");
	});	
	
	$('#con_one_1').on('click', '.next-page-link', function(){
		contentlist();
	});
	$('#one2').click(function(){
		graphiclist();
	});
	$('#con_one_2').on('click', '.next-page-link', function(){
		graphiclist();
	});
	
	$(document).on('change', '#pic', function(){
		$('#pic_url').val('');
		$('#gsubmit').click();
	})
	$("#exec_target").load(function(){
         var data = $(window.frames['exec_target'].document.body).html();
		 
         if(data != null){
             $("#pic_url").val(data);
             $("#pic").val('');
         }
     });
});

function upload_graphic(){

	if(!$('#pic_url').val()){
		alert("{lang dzapp_zhibo:please_uppic}");
		return false;
	}
	
	$.ajax({ 
		url : 'plugin.php?id=dzapp_zhibo&mod=ajax&ac=save', 
		dataType : 'json', 
		data : {pic:$('#pic_url').val(),describe:$('#describe').val(), activity_id:{$_GET[identify]}, formhash:'{FORMHASH}'},
		async: false,
		success : function(data, status){ 
			$(".post").addClass("hide");
			if(data != '0'){
				var str="<li class=\"pic-item cl\">";
					str+="<div class=\"user cl\">";
					str+="<span class=\"user-pic\">"+data.avatar+"</span>";
					str+="<span class=\"time\">"+data.username+"<i>"+data.dateline+"</i></span>";
					str+="</div>";
					str+="<div class=\"describe\">"+data.describe+"</div>";
					str+="<img src=\""+data.pic+"\">";
					str+="</li>";
				$('.ajaxnewgraphic').prepend(str);
			}
		},
		error : function(data, status, e){
			alert(e);
		}
	})
}


function tips(id,msg)
{
	layer.tips(msg, id, {
tips: [1, '#3595CC'],
time: 3000
});
}


function add(){
	var content= $("#content").val();
	
	if(content.trim()==''){
		//tips('#content',"{lang dzapp_zhibo:please_comments}");
		document.getElementById("content").placeholder="{lang dzapp_zhibo:please_comments}";
		//alert("{lang dzapp_zhibo:please_comments}");
		return;
	}

	$.ajax({
		type:"POST",
		url:"plugin.php?id=dzapp_zhibo",
		data:"mod=ajax&ac=add_comment&type={$ac}&identify={$_GET[identify]}&content="+content+"&date="+new Date().getTime()/1000+"&formhash={FORMHASH}",
		dataType:"json",
		success:function(data){
			if(data.id>0){
				alert("{lang dzapp_zhibo:submitted_successfully}");
				var str="<li class=\"ct-item cl\" data-comment-id=\""+data.id+"\">";
					str+="<div class=\"fl\">"+data.avatar+"</div>";
					str+="<div class=\"ct-content\">";
					str+="<i>"+data.username+" :</i>"+data.message;
					str+="</div>";
					str+="</li>";
				
				$('.ajaxnewcomment').prepend(str);
			}else{
				alert("{lang dzapp_zhibo:add_failed}");
			}
			$(".post").addClass("hide");
		}
	});
}

function reloadpage(){
	contentlist();
}

setInterval("getnewcomment()", 3000);
function getnewcomment(){
	$.ajax({
		type:"POST",
		url:"plugin.php?id=dzapp_zhibo",
		data:"mod=ajax&ac=new_comment&identify={$_GET[identify]}",
		dataType:"json",
		success:function(list){
			var content=$(".ajaxnewcomment"), str = '';
			if(list.length > 0){
				for(var i=0;i<list.length;i++){
					var is_have = false;
					$('[data-comment-id]').each(function(){
						if(list[i].comment_id ==  $(this).attr('data-comment-id')){
							is_have = true;
						}
					});
					if(!is_have){
						str="<li class=\"ct-item cl\" data-comment-id=\""+list[i].comment_id+"\">";
						str+="<div class=\"fl\">"+list[i].avatar+"</div>";
						str+="<div class=\"ct-content\">";
						str+="<i>"+list[i].username+" :</i>"+list[i].message;
						str+="</div>";
						str+="</li>";
						content.prepend(str);
					}
				}
			}
		}
	});
}

function contentlist(){
	
	$.ajax({
		type:"POST",
		url:"plugin.php?id=dzapp_zhibo",
		data:"mod=ajax&ac=comment&identify={$_GET[identify]}&page="+page,
		dataType:"json",
		success:function(list){
			var content=$(".ajaxnewcomment"), str = '';
			if(list.length > 0){
				for(var i=0;i<list.length;i++){
					str="<li class=\"ct-item cl\" data-comment-id=\""+list[i].comment_id+"\">";
					str+="<div class=\"fl\">"+list[i].avatar+"</div>";
					str+="<div class=\"ct-content\">";
					str+="<i>"+list[i].username+" :</i>"+list[i].message;
					str+="</div>";
					str+="</li>";
					content.append(str);
				}
				page++;
				if(list.length < 10)
					content.parent().find('.load-more').html('<a class="more" href="javascript:void(0);">--{lang dzapp_zhibo:without}--</a>');
			}else{
				content.parent().find('.load-more').html('<a class="more" href="javascript:void(0);">--{lang dzapp_zhibo:without}--</a>');
			}
		}
	});
}

function graphiclist(){
	$.ajax({
		type:"POST",
		url:"plugin.php?id=dzapp_zhibo",
		data:"mod=ajax&ac=graphic&identify={$_GET[identify]}&page="+gpage,
		dataType:"json",
		success:function(list){
			var content=$(".ajaxnewgraphic"), str = '';
			if(list.length > 0){
				for(var i=0;i<list.length;i++){
					str="<li class=\"pic-item cl\">";
					str+="<div class=\"user cl\">";
					str+="<span class=\"user-pic\">"+list[i].avatar+"</span>";
					str+="<span class=\"time\">"+list[i].username+"<i>"+list[i].dateline+"</i></span>";
					str+="</div>";
					str+="<div class=\"describe\">"+list[i].describe+"</div>";
					str+="<img src=\""+list[i].pic+"\">";
					str+="</li>";
					content.append(str);
				}
				gpage++;
				if(list.length < 10)
					content.parent().find('.load-more').html('<a class="more" href="javascript:void(0);">--{lang dzapp_zhibo:without}--</a>');
			}else{
				content.parent().find('.load-more').html('<a class="more" href="javascript:void(0);">--{lang dzapp_zhibo:without}--</a>');
			}
		}
	});
}

 function setTab(name,cursel,n){ 
        for(i=1;i<=n;i++){ 
            var menu=document.getElementById(name+i); 
            var con=document.getElementById("con_"+name+"_"+i); 
            menu.className=i==cursel?"active":""; 
            con.style.display=i==cursel?"block":"none"; 
        } 
    }
</script>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script> 
<script type="text/javascript">
wx.config({
	//debug: true,
	appId: '$_G[appId]',
	timestamp: $_G[timestamp],
	nonceStr: '$_G[nonceStr]',
	signature: '$_G[signature]',
	jsApiList: [
		'onMenuShareTimeline',
		'onMenuShareAppMessage',
		'onMenuShareQQ',
		'onMenuShareWeibo',
		'chooseWXPay',
	]
});
wx.ready(function () {

     wx.onMenuShareTimeline({
          title: '$_G[weixin][title]',
          link: '$_G[weixin][link]',
          imgUrl: '$_G[weixin][imgUrl]',
          success: function (res) {},
     });
    wx.onMenuShareAppMessage({
          title: '$_G[weixin][title]',
          desc: '$_G[weixin][desc]',
          link: '$_G[weixin][link]',
          imgUrl: '$_G[weixin][imgUrl]',
          success: function (res) {},
    });
    wx.onMenuShareQQ({
          title: '$_G[weixin][title]',
          desc: '$_G[weixin][desc]',
          link: '$_G[weixin][link]',
          imgUrl: '$_G[weixin][imgUrl]',
          success: function (res) {},
    });
    wx.onMenuShareWeibo({
          title: '$_G[weixin][title]',
          desc: '$_G[weixin][desc]',
          link: '$_G[weixin][link]',
          imgUrl: '$_G[weixin][imgUrl]',
          success: function (res) {},
    });
	$("[data-gift]").on('click', function() {
		var formobj = $('#payform');
		
		var data = {identify:$('#identify').val(), gift_id:$(this).attr('data-gift'), formhash:$('#formhash').val(), 'paysubmit':1};
		
		$.ajax({
			type:'POST',
			url: formobj.attr('action'),
			data:data,
			dataType:'json',
			async: false,
			success: function(s) {
		
				wx.chooseWXPay({
					timestamp: s.timeStamp, 
					nonceStr: s.nonceStr, 
					package: s.package, 
					signType: s.signType, 
					paySign: s.paySign, 
					success: function (res) {
						window.location.href = s.href;
					}
				});
			},
			error:function(){
				alert(222)
			}
		});
		return false;
	});
});
</script>
<!--{template dzapp_zhibo:footer}-->